import uuid

from app.agent.toolcall import ToolCallAgent
from app.logger import logger
from app.tool.tavily_search import tavily_search

agent = ToolCallAgent(
    name="Test tool call agent",
    tools=[tavily_search],
    max_steps=1
)


async def target(inputs: dict) -> dict:
    agent.thread_id = uuid.uuid4()
    agent.input_msg_of_this_round.append({"role": "user", "content": inputs["question"]})
    res = await agent.run()
    logger.debug(f"target last message: {res[-1]["messages"][-1].content.strip()}")
    return {"answer": res[-1]["messages"][-1].content.strip()}
